package com.awesome.media;

import android.content.Context;
import android.view.Surface;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;

/**
 * Author: JFangZ
 * Email:janezhang1901@163.com
 * Date: 2020/4/29 15:59
 * Description:Player 基类
 */
public abstract class AbsPlayer implements IMediaPlayer {
    protected String TAG = getClass().getSimpleName();
    protected Context mContext;
    protected IMediaPlayerListener mMediaPlayerListener;
    protected Surface mSurface;
    protected ScheduledFuture<?> mScheduledFuture;
    /**
     * 执行延时任务的线程池
     */
    protected ScheduledExecutorService mScheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
        @Override
        public Thread newThread(Runnable runnable) {
            Thread thread = new Thread(runnable);
            thread.setName("MediaPlayer");
            thread.setDaemon(true);
            return thread;
        }
    });

    public AbsPlayer(Context context) {
        mContext = context;
    }

    @Override
    public void setMediaPlayerListener(IMediaPlayerListener mediaPlayerListener) {
        mMediaPlayerListener = mediaPlayerListener;
    }

}
